<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/picker.css" />
		<link rel="stylesheet" href="../css/poppicker.css" />
		<link rel="stylesheet" type="text/css" href="../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../css/datepicker3.css" />
		<link rel="stylesheet" href="../css/member.css" />

	</head>

	<body>
		<header class="mui-bar mui-bar-nav public-color">
			<a id="shan" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">人才数据填写表</h1>
			<!--//<button class="mui-pull-right edit" id="btn" style="background-color: #ff7831;border: 0px;color: #efecec; font-size: 16px;">保存</button>-->
		</header>
		<div class="mui-content address_content">
			<form class="mui-input-group">
				<div class="address_mor clearfix" id='fuj'>
					<span>显示附近</span>
					<div id="isdefault" class="mui-switch mui-switch-mini" data-mystate="1">
						<div id="isdefault2" class="mui-switch-handle"></div>
						<input type="hidden" id="default" value="1">
					</div>
				</div>
				<div class="mui-input-row mui-select">
					<label>就业状态：</label>
					<select id='employment'>
						<option value="0">请选择就业状态</option>
						<option value="1">正在找工作</option>
						<option value="2">在做临时工</option>
						<option value="3">在职</option>
						<option value="4">其他</option>
					</select>
				</div>
				<div class="mui-input-row">
					<label>姓&nbsp;&nbsp;&nbsp;名：</label>
					<input type="text" id="real_name" class="mui-input-group" placeholder="请输入姓名">
				</div>
				<div class="mui-input-row">
					<label>性别：</label>
					<select id='sex'>
						<option value="1">男</option>
						<option value="2">女</option>
					</select>

				</div>
				<div class="mui-input-row">
					<label>出生年月：</label>
					<input type="text" name="birthday" id="birth" class="datetimepicker" id="datetimepicker" placeholder="请选择出生年月">
				</div>
				<div class="mui-input-row">
					<label>最高学历：</label>
					<select id='record'>
						<option value="0">请选择学历</option>
						<option value="1">小学</option>
						<option value="2">初中</option>
						<option value="3">高中</option>
						<option value="4">大学</option>
						<option value="5">其它</option>
					</select>
				</div>

				<div class="mui-input-row">
					<label>工作种类：</label>
					<select id='competent'>
						<option value="0">期望胜任的岗位</option>
						<option value="1">农业</option>
						<option value="2">服务业</option>
						<option value="3">工业</option>
						<option value="4">其他</option>
					</select>

				</div>
				<div class="mui-input-row">
					<label>职&nbsp;&nbsp;&nbsp;称：</label>
					<input type="text" id="certification" class="mui-input-group" placeholder="请选择职称及资格证">
				</div>
				<div class="mui-input-row">
					<label>期望月收入：</label>
					<select id='m_money'>
						<option value="0">选择期望收入</option>
						<option value="1">2000以下</option>
						<option value="2">4000以内</option>
						<option value="3">6000以内</option>
						<option value="4">6000以上</option>
					</select>
				</div>
				<div class="mui-input-row">
					<label>就业地点：</label>
					<select id='address'>
						<option value="0">期望就业的地点</option>
						<option value="1">本乡镇</option>
						<option value="2">本县</option>
						<option value="3">本市</option>
						<option value="4">本省</option>
						<option value="5">其它省份</option>
					</select>

				</div>
				<div class="mui-input-row">
					<label>就业时间：</label>
					<select id='time'>
						<option value="0">选择就业时间</option>
						<option value="1">长期</option>
						<option value="2">兼职</option>
						<option value="3">临时工</option>
					</select>
				</div>
				<div class="mui-input-row">
					<label>你的简历：</label>
					<input type="text" id="resume" class="mui-input-group" placeholder="请填写你的简历">
				</div>

				<br/>

			</form>
			<div class="address_mor clearfix">

				<div class="gerzl_btn" id="btn" onclick="func1()">
					<a href="#">保存</a>
				</div>
			</div>
			<input type="hidden" id='order_ids'>
			<script type="text/javascript" src="../js/jquery.min.js"></script>
			<script type="text/javascript" src="../js/bootstrap-datepicker.js"></script>
			<script src="../js/layer/layer.min.js"></script>
			<script src="../js/mui.min.js"></script>
			<script src="../js/castapp.js"></script>
			<script src="../js/picker.js"></script>
			<script src="../js/poppicker.js"></script>
			<script src="../js/city.data-3.js"></script>
			<script src="../js/app.js"></script>
			<script>
				var member = JSON.parse(localStorage.getItem("member"));
				$(".datetimepicker").datepicker({
					language: "zh-CN",
					autoclose: true, //选中之后自动隐藏日期选择框
					clearBtn: true, //清除按钮
					todayBtn: true, //今日按钮
					format: "yyyy-mm-dd" //日期格式，详见 http://bootstrap-datepicker.readthedocs.org/en/release/options.html#format
				});
				$(function() {

					$.ajax({
						//type: 'post',
						url: APP.api_url + 'Talent/index',
						dataType: 'jsonp',
						data: {
							u_id: member['id'], //uid
						},
						success: function(data) {
							var json = data.data;
							if(data.code == 200) {
								document.getElementById("real_name").value = json.real_name;
								document.getElementById("birth").value = json.birth;
								document.getElementById("employment").options[json.employment].selected = true;
								document.getElementById("record").options[json.record].selected = true;
								document.getElementById("competent").options[json.competent].selected = true;
								document.getElementById("m_money").options[json.m_money].selected = true;
								document.getElementById("address").options[json.address].selected = true;
								document.getElementById("time").options[json.time].selected = true;
								document.getElementById("certification").value = json.certification;
								document.getElementById("resume").value = json.resume;
								if(json.is_online == 2) {
									$("#isdefault2").css("transition-duration", "0.2s");
									$("#isdefault2").css("transform", "translate(16px, 0px)");
									$("#isdefault").addClass("mui-active");
									$("#isdefault").data("mystate", 2);
								}
								var sexhtml="";
									if(json.sex == 1){
										sexhtml+='<option value="1" selected>男</option><option value="2">女</option>';
									}else{
										sexhtml+='<option value="1">男</option><option value="2" selected>女</option>';
									}
									document.getElementById('sex').innerHTML=sexhtml;
							} else {
								if(member['real_name']) {
									document.getElementById("real_name").value = member['real_name'];
								}
								if(member['sex'] == 1) {
									document.getElementById("sex").options[1].selected = true;
								} else {
									document.getElementById("sex").options[2].selected = true;
								}
								if(member['birthday']) {
									document.getElementById("birth").value = member['birthday'];
								}

							}
						}
					});

				});

				function func1() {
					var isdefault = $("#isdefault").data("mystate");
					if($('#employment').val() == 0) {
						layer.msg('请选择就业状态', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					if($('#real_name').val() == '') {
						layer.msg('请填写姓名', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					if($('#birth').val() == '') {
						layer.msg('请选择出生年龄', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					if($('#record').val() == 0) {
						layer.msg('请选择学历', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					if($('#competent').val() == 0) {
						layer.msg('请选择岗位', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					if($('#m_money').val() == 0) {
						layer.msg('请选择期望工资', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					if($('#address').val() == 0) {
						layer.msg('请选择工作地点', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					if($('#time').val() == 0) {
						layer.msg('请选择就业时间', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					if($('#certification').val() == 0) {
						layer.msg('请填写职称', {
							icon: 1,
							time: 1500,
							shade: 0.1
						})
						return false;
					}
					$.ajax({
						//type: 'post',
						url: APP.api_url + 'Talent/update',
						dataType: 'jsonp',
						data: {
							is_online: isdefault, //是否附近
							u_id: member['id'], //uid
							employment: $('#employment').val(), //就业状态
							real_name: $('#real_name').val(), //
							birth: $('#birth').val(), //
							record: $('#record').val(), //学历
							competent: $('#competent').val(), //种类
							m_money: $('#m_money').val(), //月工资
							address: $('#address').val(), //地点
							time: $('#time').val(), //时间
							certification: $('#certification').val(), //职称
							resume: $('#resume').val(), //简历
							sex: $('#sex').val(), //简历
						},
						success: function(data) {
							layer.msg(data.data, {
								icon: 1,
								time: 1500,
								shade: 0.1
							}, function(index) {
								window.location.href = "";
							});
						}
					});

				}
			</script>
			<script>
				$("#isdefault").click(function() {
					var my = $("#isdefault").data("mystate");
					var my_state = 1;
					if(parseInt(my) == 1) {
						$("#isdefault").data("mystate", 2);
					} else {
						$("#isdefault").data("mystate", 1);
					}
				})
			</script>